ArrayList <Bubble> bubbles;
int countDown;

void setup() {
  //size(800,600);
  
  bubbles = new ArrayList();
  countDown = round ( random (25, 100) ); 

  bubbles.add( new Bubble() );
}

void draw() {
  background( 0 );

  drawBubbles();

  countDown--;
  if ( countDown <= 0 ) {
    bubbles.add( new Bubble() );
    countDown = round ( random (25, 100) );
  }
}

void drawBubbles() {
  Iterator itr = bubbles.iterator();
  while ( itr.hasNext () ) {
    Bubble tempBubble = (Bubble)itr.next();

    tempBubble.draw();
  }
}

void mouseClicked(){
  Iterator itr = bubbles.iterator();
  while ( itr.hasNext () ) {
    Bubble tempBubble = (Bubble)itr.next();

    tempBubble.blowBubble(motionX , motionY);
  }
}
